<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="_path" value="${pageContext.request.contextPath}"></c:set>
<form id="abbQueryForm" style="margin:10;text-align: center;">
	<table width="100%">
		<tr>
			<td>身份证：</td>
			<td>
				<input name="q@ownercard" style="width: 150"/>
			</td>
			<td>一卡通卡号：</td>
			<td>
				<input name="q@abaid" style="width: 150"/>
			</td>
			<td>操作流水号：</td>
			<td>
				<input name="q@id" class="easyui-numberbox" title="该字段精确匹配,请输入流水号整数部分" style="width: 150"/>
			</td>
			<td align="center">
				<a href="javascript:void(0);" onclick="clearAbbForm()" class="easyui-linkbutton" iconCls="icon-search">清空</a>
			</td>
		</tr>
		<tr>
			<td>起始日期：</td>
			<td>
				<input class="easyui-datebox" name="q@creatdatefrom" style="width: 150"/>
			</td>
			<td>结束日期：</td>
			<td>
				<input class="easyui-datebox" name="q@creatdateto" style="width: 150"/>
			</td>
			<td>操作员：</td>
			<td>
				<input name="q@creatuserid" style="width: 150">
			</td>
			<td align="center"><a href="javascript:void(0);" onClick="doSearchAbb()" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
		</tr>
	</table>
</form>
<div id="abbTable"></div>
<script>
jQuery(function($){
	$('#abbTable').datagrid({
		title:'充值明细列表',//标题
		method:'post',
		iconCls:'icon-edit',//图标
		singleSelect:false,//多选
		height:428,
		fitColumns: true,//自动调整各列，用了这个属性，下面各列的宽度值就只是一个比例。
		striped: true,//奇偶行颜色不同
		collapsible:false,//可折叠
		sortName: 'id', //排序的列
		sortOrder: 'desc', //倒序
		remoteSort: true, //服务器端排序
		idField:'id', //主键字段
		queryParams:{}, //查询条件
		pagination:true, //显示分页
		rownumbers:true, //显示行号
		showFooter:true,
		columns:[[
			{field:'creatdatetime',title:'充值日期',width:30,sortable:true},
			{field:'abaid',title:'卡号',width:20,sortable:true},
			{field:'id',title:'充值流水号',width:20,sortable:true,
				formatter:function(v){
					if(v == "" || v == null || v == "null")
						return "";
					var a = "" + v;
					while(a.length < 8){
						a = "0" + a;
					}
					return a;
				}
			},
			{field:'creditflag',title:'充值类型',width:20,sortable:true,formatter:function(v){if(v==1){return '充值';}else if(v==2){return '冲账';}else if(v==3){return "开卡";}}},
			{field:'emoneybalance',title:'电字帐户充值前金额',width:30,sortable:true},
			{field:'emoney',title:'充值金额',width:15,sortable:true},
			{field:'emoneybalance.emoney',title:'余额',width:15,sortable:false,
				formatter:function(v,r){
					if(r.creditflag == 1 || r.creditflag == 3){
						return r.emoneybalance + r.emoney;
					}else if(r.creditflag == 2){
						return r.emoneybalance - r.emoney;
					}else{
						return "";
					}
				}
			},
			{field:'moneybalance',title:'电子钱包充值前金额',width:30,sortable:true},
			{field:'money',title:'充值金额',width:15,sortable:true},
			{field:'moneybalance.emoney',title:'余额',width:15,sortable:false,
				formatter:function(v,r){
					if(r.creditflag == 1 || r.creditflag == 3){
						return r.moneybalance + r.money;
					}else if(r.creditflag == 2){
						return r.emoneybalance - r.emoney;
					}else{
						return "";
					}
				}
			},
			{field:'creatuserid',title:'操作员',width:20,sortable:true}
		]],
		toolbar:[{
			text:'导出Excel',
			iconCls:'icon-print',
			handler:function(){
				$('#abbQueryForm').attr('target','_blank');
				$('#abbQueryForm').attr('method','post');
				$('#abbQueryForm').attr('action','${_path}/abb/exportQueryList');
				$('#abbQueryForm').submit();
			}
		},'-'],
		onLoadSuccess:function(){
			$('#abbTable').datagrid('clearSelections'); //一定要加上这一句，要不然datagrid会记住之前的选择状态，删除时会出问题
		}
	});
});
//表格查询
function doSearchAbb(){
	var params = $('#abbTable').datagrid('options').queryParams;//先取得 datagrid的查询参数
	var fields =$('#abbQueryForm').serializeArray();//自动序列化表单元素为JSON对象
	$.each( fields, function(i, field){
		params[field.name] = field.value;//设置查询参数
	}); 
	$('#abbTable').datagrid({url:"abb/queryList"});
}
//清空查询条件
function clearAbbForm(){
	$('#abbQueryForm').form('clear');
	doSearchAbb();
}
</script>